/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.business.customer.core.service.processor.update;

import cn.hutool.core.lang.Assert;
import info.peigen.hotpot.business.customer.core.domain.Customer;
import info.peigen.hotpot.business.customer.core.service.processor.base.AbstractCustomerServiceProcessor;
import info.peigen.hotpot.business.customer.facade.order.update.CustomerUpdateOrder;
import info.peigen.hotpot.common.core.domain.Image;
import info.peigen.hotpot.common.service.base.processor.Processor;
import info.peigen.hotpot.common.service.base.processor.ProcessorServiceContext;
import org.noear.solon.annotation.Component;

/**
 * <b>(CustomerUpdateAvatarProcessor)</b>
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2023/8/30
 */
@Component
public class CustomerUpdateAvatarProcessor extends AbstractCustomerServiceProcessor implements Processor {
    @Override
    public Integer level() {
        return 50;
    }

    @Override
    public void execute(ProcessorServiceContext serviceContext) {
        CustomerUpdateOrder order    = (CustomerUpdateOrder) serviceContext.getOrder();
        Customer            customer = (Customer) serviceContext.getDomain();
        Assert.notNull(customer);
        customer.getCustomerBase().setAvatar(Image.builder().path(order.getAvatar()).build());
        serviceContext.getResult().setSuccessNotFee();
    }

}
